From: Brion Vibber Date: Tue, 5 Oct 2004 07:35:19 +0000 (+0000) Subject: Rasterize plain image views of SVG files at default size (currently 512px wide, maybe... X-Git-Tag: 1.5.0alpha1~1651 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=1111b47477cc9ad5bb06043100501448f22d3898;p=lhc%2Fweb%2Fwiklou.git Rasterize plain image views of SVG files at default size (currently 512px wide, maybe not the best). Prefer ImageMagick over GD when setting up LocalSettings.php --- diff --git a/config/index.php b/config/index.php index be5cffe75f..4aaaa9fbc4 100644 --- a/config/index.php +++ b/config/index.php @@ -279,20 +279,24 @@ if( $conf->zlib ) { } $conf->ImageMagick = false; +$imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); +foreach( $imcheck as $dir ) { + $im = "$dir/convert"; + if( file_exists( $im ) ) { + print "
  • Found ImageMagick: $im; image thumbnailing will be enabled if you enable uploads.
  • \n"; + $conf->ImageMagick = $im; + break; + } +} $conf->HaveGD = function_exists( "imagejpeg" ); if( $conf->HaveGD ) { - print "
  • Found GD graphics library built-in, image thumbnailing will be enabled if you enable uploads.
  • \n"; -} else { - $imcheck = array( "/usr/bin", "/usr/local/bin", "/sw/bin" ); - foreach( $imcheck as $dir ) { - $im = "$dir/convert"; - if( file_exists( $im ) ) { - print "
  • Found ImageMagick: $im; image thumbnailing will be enabled if you enable uploads.
  • \n"; - $conf->ImageMagick = $im; - break; - } + print "
  • Found GD graphics library built-in"; + if( !$conf->ImageMagick ) { + print ", image thumbnailing will be enabled if you enable uploads"; } + print ".
  • \n"; +} else { if( !$conf->ImageMagick ) { print "
  • Couldn't find GD library or ImageMagick; image thumbnailing disabled.
  • \n"; } diff --git a/includes/Image.php b/includes/Image.php index 24c7896293..3cb0a09fd1 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -121,6 +121,14 @@ class Image { return $this->url; } + + function getViewURL() { + if( $this->mustRender() ) { + return $this->createThumb( $this->getWidth() ); + } else { + return $this->getURL(); + } + } /** * Return the image path of the image in the @@ -319,7 +327,7 @@ class Image if( $width > $this->width ) { # Don't make an image bigger than the source - return $this->getURL(); + return $this->getViewURL(); } if ( (! file_exists( $thumbPath ) ) || ( filemtime($thumbPath) < filemtime($this->imagePath) ) ) { @@ -461,7 +469,15 @@ class Image $this->historyLine = 0; } - + /** + * Return true if the file is of a type that can't be directly + * rendered by typical browsers and needs to be re-rasterized. + * @return bool + */ + function mustRender() { + return ( $this->extension == 'svg' ); + } + } //class diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 1668197732..f8b4c51d6e 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -39,7 +39,7 @@ class ImagePage extends Article { { global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgUseImageResize; $this->img = Image::newFromTitle( $this->mTitle ); - $url = $this->img->getUrl(); + $url = $this->img->getViewURL(); $anchoropen = ''; $anchorclose = ''; if ( $wgUseImageResize && $wgUser->getOption( 'imagesize' ) != '' ) { diff --git a/includes/Skin.php b/includes/Skin.php index 652149aa75..a30d198c10 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1668,7 +1668,7 @@ class Skin { function makeImageLinkObj( $nt, $alt = '' ) { global $wgContLang, $wgUseImageResize; $img = Image::newFromTitle( $nt ); - $url = $img->getURL(); + $url = $img->getViewURL(); $align = ''; $prefix = $postfix = ''; @@ -1799,7 +1799,7 @@ class Skin { function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) { global $wgStylePath, $wgContLang; # $image = Title::makeTitleSafe( NS_IMAGE, $name ); - $url = $img->getURL(); + $url = $img->getViewURL(); #$label = htmlspecialchars( $label ); $alt = preg_replace( '/<[^>]*>/', '', $label); @@ -1843,7 +1843,7 @@ class Skin { { $manual_title = Title::makeTitleSafe( NS_IMAGE, $manual_thumb ); #new Title ( $manual_thumb ) ; $manual_img = Image::newFromTitle( $manual_title ); - $thumbUrl = $manual_img->getURL(); + $thumbUrl = $manual_img->getViewURL(); if ( $manual_img->exists() ) { $width = $manual_img->getWidth();